package com.migo.controller;

import com.migo.entity.ZipMatchEntity;
import com.migo.service.ZipMatchService;
import com.migo.utils.PageUtils;
import com.migo.utils.Query;
import com.migo.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * OTA固件Match表
 * 
 * @author powervision
 * @email wes.wang@powervision.me
 * @date 2020-04-22 16:34:09
 */
@RestController
@RequestMapping("zipmatch")
public class ZipMatchController {
	@Autowired
	private ZipMatchService zipMatchService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("zipmatch:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<ZipMatchEntity> zipMatchList = zipMatchService.queryList(query);
		int total = zipMatchService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(zipMatchList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("zipmatch:info")
	public R info(@PathVariable("id") Integer id){
		ZipMatchEntity zipMatch = zipMatchService.queryObject(id);
		
		return R.ok().put("zipMatch", zipMatch);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("zipmatch:save")
	public R save(@RequestBody ZipMatchEntity zipMatch){
		zipMatchService.save(zipMatch);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("zipmatch:update")
	public R update(@RequestBody ZipMatchEntity zipMatch){
		zipMatchService.update(zipMatch);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("zipmatch:delete")
	public R delete(@RequestBody Integer[] ids){
		zipMatchService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
